//
//  JMStudyCircleCell.m
//  VoluntaryStar
//
//  Created by xiaorui on 15/9/6.
//  Copyright (c) 2015年 ios. All rights reserved.
//

#import "JMStudyCircleCell.h"
#import "JMHeader.h"
#import "UIViewExt.h"
#import "NSString+date.h"

@interface JMStudyCircleCell ()

@property (nonatomic, strong) UIImageView *bottomLineImageView;

@property (nonatomic, strong) UIImageView *lineImageView;

@end

@implementation JMStudyCircleCell


- (UIImageView *)iconImageView
{
    if (!_iconImageView) {
        UIImageView *imageView = [[UIImageView alloc]init];
        imageView.contentMode = UIViewContentModeScaleAspectFill;
        _iconImageView = imageView;
        [self addSubview:_iconImageView];
    }
    return _iconImageView;
}
- (UILabel *)nameLabel
{
    if (!_nameLabel) {
        UILabel* label = [[UILabel alloc]init];
        label.backgroundColor = [UIColor clearColor];
        label.textColor = [UIColor blackColor];
        label.font = [UIFont systemFontOfSize:14.0f];
        _nameLabel = label;
        [self addSubview:_nameLabel];
    }
    return _nameLabel;
}

- (UILabel *)timelabel
{
    if (!_timelabel) {
        UILabel* label = [[UILabel alloc]init];
        label.backgroundColor = [UIColor clearColor];
        label.textColor = UIColorFromRGB(0xcbcbcb);
        label.font = [UIFont systemFontOfSize:12.0f];
        _timelabel = label;
        [self addSubview:_timelabel];
    }
    return _timelabel;
}

- (UILabel *)typeLabel
{
    if (!_typeLabel) {
        UILabel* label = [[UILabel alloc]init];
        label.backgroundColor = [UIColor clearColor];
        label.textColor = [UIColor blackColor];
        label.font = [UIFont systemFontOfSize:13.0f];
        label.layer.masksToBounds =YES;
        label.layer.borderWidth = 0.5;
        label.layer.cornerRadius = 4;
        label.textAlignment =NSTextAlignmentCenter;
        _typeLabel = label;
        [self addSubview:_typeLabel];
    }
    return _typeLabel;
}

- (JMTapImageView *)infoImageView
{
    if (!_infoImageView) {
        JMTapImageView *imageView = [[JMTapImageView alloc]init];
//        imageView.contentMode = UIViewContentModeScaleAspectFill;
        imageView.layer.masksToBounds =YES;
        imageView.layer.borderColor = [UIColorFromRGB(0xc4c4c4) CGColor];
        imageView.layer.borderWidth= 0.5;
        imageView.backgroundColor = [UIColor clearColor];
        _infoImageView = imageView;
        [self addSubview:_infoImageView];
    }
    return _infoImageView;
}
- (UIImageView *)bottomLineImageView
{
    if (!_bottomLineImageView) {
        UIImageView *imageView = [[UIImageView alloc]init];
        imageView.image = [UIImage imageNamed:@"projectImage.bundle/line_image"];
        imageView.contentMode = UIViewContentModeScaleAspectFill;
        imageView.backgroundColor = [UIColor clearColor];
        _bottomLineImageView = imageView;
        [self addSubview:_bottomLineImageView];
    }
    return _bottomLineImageView;
}
- (UIImageView *)lineImageView
{
    if (!_lineImageView) {
        UIImageView *imageView = [[UIImageView alloc]init];
        imageView.image = [UIImage imageNamed:@"projectImage.bundle/line_image"];
        imageView.contentMode = UIViewContentModeScaleAspectFill;
        imageView.backgroundColor = [UIColor clearColor];
        _lineImageView = imageView;
        [self addSubview:_lineImageView];
    }
    return _lineImageView;
}


- (UIButton *)answerBnt
{
    if (!_answerBnt) {
        UIButton *button = [[UIButton alloc]init];
        [button setTitleColor:UIColorFromRGB(0x9b9b9b) forState:UIControlStateNormal];
        [button setTitle:@"抢答" forState:UIControlStateNormal];
        button.titleLabel.font = [UIFont systemFontOfSize:13];
        [button setImage:[UIImage imageNamed:@"projectImage.bundle/qiangda"] forState:UIControlStateNormal];
        _answerBnt = button;
        [self addSubview:_answerBnt];
    }
    return _answerBnt;
}

- (UIButton *)countBnt
{
    if (!_countBnt) {
        UIButton *button = [[UIButton alloc]init];
        [button setTitleColor:UIColorFromRGB(0xc4c4c4) forState:UIControlStateNormal];
        button.titleLabel.font = [UIFont systemFontOfSize:13];
        _countBnt = button;
        [self addSubview:_countBnt];
    }
    return _countBnt;
}


- (void)layoutSubviews{
    [super layoutSubviews];
    self.iconImageView.frame = CGRectMake(5, 5, UI_SCREEN_WITH *0.09375, UI_SCREEN_WITH *0.09375);
    self.iconImageView.layer.masksToBounds = YES;
    self.iconImageView.layer.cornerRadius = UI_SCREEN_WITH *0.09375/2.0;

    self.nameLabel.frame =CGRectMake(self.iconImageView.frameRight + 8, self.iconImageView.frameTop, 150, UI_SCREEN_WITH *0.09375/2.0);

    self.timelabel.frame = CGRectMake(self.nameLabel.frameLeft, self.nameLabel.frameBottom + 4, 130, UI_SCREEN_WITH *0.09375/2.0);

    CGSize size = [self.typeLabel.text sizeWithFont:[UIFont systemFontOfSize:13] andMaxSize:CGSizeMake(UI_SCREEN_WITH, 25)];
    self.typeLabel.frame = CGRectMake(UI_SCREEN_WITH - size.width - 15, 6, size.width + 5, size.height);
    
    self.infoImageView.frame = CGRectMake(15, self.iconImageView.frameBottom + 10, UI_SCREEN_WITH - 30, UI_SCREEN_WITH *0.28125);
    
    self.lineImageView.frame = CGRectMake(0, self.infoImageView.frameBottom  + UI_SCREEN_WITH *0.050125, UI_SCREEN_WITH, 0.5);
    
    self.answerBnt.frame = CGRectMake(20,self.lineImageView.frameBottom ,60, self.frameHeight - self.lineImageView.frameBottom);
    self.answerBnt.imageEdgeInsets = UIEdgeInsetsMake(0,-self.answerBnt.frameWidth + 40, 0, 0);
    self.answerBnt.titleEdgeInsets = UIEdgeInsetsMake(0,-self.answerBnt.frameWidth + 60, 0, 8);
    
    self.countBnt.frame = CGRectMake(UI_SCREEN_WITH - 70,self.lineImageView.frameBottom ,60, self.frameHeight - self.lineImageView.frameBottom);
    
    self.bottomLineImageView.frame = CGRectMake(0, self.frameHeight - 0.5, UI_SCREEN_WITH, 0.5);
}


- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
